package com.dmap.officialwebsite.controller.background;

import com.dmap.base.vo.BaseVo;
import com.dmap.officialwebsite.po.Company;
import com.dmap.officialwebsite.service.CompanyService;
import com.dmap.officialwebsite.vo.CompanyVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * \* User: helei
 * \* Date: 03/09/18
 * \* Description:
 * \
 */
@Api(value = "公司管理", description = "background/公司管理")
@Controller
@RequestMapping(value = "/background/dmap-officialwebsite-server/v1/company/")
public class CompanyController {

    @Resource
    private CompanyService companyService;

    @ResponseBody
    @ApiOperation(value = "查询公司列表", notes = "查询公司列表")
    @RequestMapping(value = "select/selectAll", method = RequestMethod.GET)
    public BaseVo selectAll() {
        BaseVo baseVo = new BaseVo();
        List<Company> companyList = companyService.selectAll();
        List<CompanyVo> companyVoList = new ArrayList<>();
        companyList.forEach(company -> {
            companyVoList.add(new CompanyVo(company));
        });
        baseVo.setData(companyVoList);
        return baseVo;
    }
}
